package com.demo.service.impl;

import com.demo.dao.ProjectDao;
import com.demo.dto.ProjectDto;
import com.demo.pojo.Project;
import com.demo.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName ProjectServiceImpl
 * @Description TODO
 * @Author Windy
 * @Date 2022/9/2 16:04
 * @Version 1.0
 **/
@Service("projectService")
//@Transactional
public class ProjectServiceImpl implements ProjectService {
    @Autowired
    ProjectDao projectDao;
    @Override
    public ProjectDto findProjectById(int pid) {
        return projectDao.findProjectById(pid);
    }

    @Override
    public ProjectDto findProjectByName(String name) {
        return projectDao.findProjectByName(name);
    }

    @Override
    public boolean deletedProject(Project project) {
        int i = projectDao.deletedProject(project);
        if (i > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean updateProjectById(Project project) {
        int i = projectDao.updateProjectById(project);
//        int a=1/0;
        return i>=0;
    }

    @Override
    public boolean insertProject(Project project) {
        return projectDao.insertProject(project)>=0;
    }

    @Override
    public List<ProjectDto> findAll() {
        return projectDao.findAll();
    }
}
